class Solution(object):
    def levelOrder(self, root):
        """
        :type root: TreeNode
        :rtype: List[List[int]]
        """
        def BFS(root):
            path = []
            if root == None:
                return []
            queue = []
            queue.append(root)
            while len(queue) > 0:
                cur_path = []
                for i in range(len(queue)):
                    node = queue[0]
                    queue.pop(0)
                    cur_path.append(node.val)
                    if node.left is not None:
                        queue.append(node.left)
                    if node.right is not None:
                        queue.append(node.right)
                path.append(cur_path[:])  
            return path 
        path = []
        return BFS(root)
